package com.atguigu.springcloud.service;

import com.atguigu.springcloud.entity.CommonResult;
import com.atguigu.springcloud.entity.Payment;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * Feign调用微服务
 * FeignClient注解需要添加所需要调用的微服务的名称
 *
 * @author Tu
 * @date 2023/5/1 14:55
 */
@Component
@FeignClient(value = "cloud-eureka-provider")
public interface PaymentFeignService {

    /**
     * 通过id查询支付信息
     *
     * @param id
     * @return
     */
    @GetMapping("/api/v1/payment/selById/{id}")
    CommonResult selPaymentById(@PathVariable("id") Long id);

    /**
     * 新增支付信息
     *
     * @param payment
     * @return
     */
    @PostMapping(value = "/api/v1/payment/insert")
    CommonResult insertPayment(@RequestBody Payment payment);

    /**
     * 模拟feignClient调用超时
     *
     * @return
     */
    @GetMapping(value = "/api/v1/payment/timeout")
    String paymentFeignTimeout();

}
